----------------------------------------------------------------------------------------------------------------------------------------------------
--[[

【坤乾否卦帽】是帽子，不会变潮湿，戴在头上只会提供70雨露值/min。刚转变时【霉运】值为777点，【霉运】降为0时转变为【乾坤泰卦帽】。
【坤乾否卦帽】的【霉运】升降和【乾坤泰卦帽】相同逻辑。(防水为0）
【坤乾否卦帽】没有存储格子，但可以放入特定物品作为“燃料”。每放入一个【蝙蝠翅膀】减少【霉运】7点，每放入一个【蝙蝠棒】减少【霉运】49点。

]]--
----------------------------------------------------------------------------------------------------------------------------------------------------
--- 物品接受
    local fix_param = {
        ["batbat"] = 49,
        ["charcoal"] = 7,
    }
    local function GetStackNum(item)
        if item.components.stackable then
            return item.components.stackable:StackSize()
        end
        return 1
    end
    local accept_test_fn = function(inst,item,doer,right_click)
        if item and fix_param[item.prefab] then
            return true
        end
    end
    local on_accept = function(inst,item,doer)
        local stack_num = GetStackNum(item)
        local delta_value = -1 * fix_param[item.prefab] * stack_num *(TUNING.HUTAO_DEBUGGING_MODE and 10 or 1)
        inst.components.hutao_com_cosmic_hat_sys_for_item:DoDelta(delta_value)
        item:Remove()
        return true
    end
    local function accept_replica_init(inst,replica_com)
        replica_com:SetTestFn(accept_test_fn)
        replica_com:SetSGAction("dolongaction")
        replica_com:SetText("hutao_equipment_cosmic_hat_ground",STRINGS.ACTIONS.CONSTRUCT.REPAIR)
    end
    local function item_accept_com_install(inst)
        inst:ListenForEvent("HUTAO_OnEntityReplicated.hutao_com_acceptable",accept_replica_init)
        if not TheWorld.ismastersim then
            return
        end
        inst:AddComponent("hutao_com_acceptable")
        inst.components.hutao_com_acceptable:SetOnAcceptFn(on_accept)
    end
----------------------------------------------------------------------------------------------------------------------------------------------------
--- 帽子逻辑
    local function hat_base_task_logic(inst)
        local owner = inst.components.hutao_com_cosmic_hat_sys_for_item:GetLinkedPlayer()
        if inst.components.equippable:IsEquipped() then
            -- owner.components.moisture:DoDelta(70/60,true)
            inst.components.equippable.equippedmoisture = 70/60 -- 每秒潮湿度增加
        end
    end
----------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------------
return function(inst)
    item_accept_com_install(inst)
    if not TheWorld.ismastersim then
        return
    end
    inst:DoPeriodicTask(1,hat_base_task_logic)
end
